#include <cstdio>
#include <deque>
#include <iostream>
#include <istream>
#include <ranges>
#include <tuple>
#include <vector>
using ll = long long;

ll n,m;
std::vector<std::vector<std::tuple<ll,ll>>> g;
std::vector<ll> in,out;
std::vector<double> dp;

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin>>n>>m;
    g.resize(n+1);
    in.resize(n+1);
    out.resize(n+1);
    for(ll i=1;i<=m;i++){
        ll u,v,w;
        std::cin>>u>>v>>w;
        in[v]++;
        out[u]++;
        g[u].emplace_back(v,w);
    }
    std::vector<ll> sorted;
    std::deque<ll> q;
    for(ll i=1;i<=n;i++){
        if(!in[i]){
            q.push_back(i);
        }
    }
    while(q.size()){
        ll top = q.front();
        q.pop_front();
        sorted.push_back(top);
        for(auto [v,w]:g[top]){
            if(!--in[v])q.push_back(v);
        }
    }
    dp.resize(n+1);
    for(ll u:std::views::reverse(sorted)){
        if(u==n)continue;
        for(auto[v,w]:g[u]){
            dp[u]+=(dp[v]+w)/out[u];
        }
    }
    printf("%.2lf\n",dp[1]);
}